﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Xml;

using Landscape.Members;

namespace Landscape.Tests {
    [TestClass]
    public class StressTest : DefaultTest {
        private TestContext testContextInstance;
        public TestContext TestContext {
            get {
                return testContextInstance;
            }
            set {
                testContextInstance = value;
            }
        }
        [TestMethod]
        public void StressNestedTemplate() {
            int iterations = 10000;
            Debug.Print(string.Format("Starting stress test with {0} iterations", iterations.ToString()));
            DateTime start = DateTime.Now;
            for (var i = 0; i < 10000; i++) {
                string result = Landscape.Renderer.Render("BasicNestedTemplate3", "<root/>");
                Debug.Assert(!string.IsNullOrEmpty(result));
            }
            TimeSpan elapsed = new TimeSpan((DateTime.Now - start).Ticks);
            Debug.Print(string.Format("Stress test with {0} iteration ran in {1} seconds", iterations.ToString(), elapsed.ToString()));
        }

        [TestMethod]
        public void StressNestedWidget() {
            int iterations = 10000;
            DateTime start = DateTime.Now;
            for (var i = 0; i < 10000; i++) {
                string result = Landscape.Renderer.RenderWidget("NestedWidget", "<root/>", "", new Dictionary<string, object>() { 
                    {"param", "OK"}
                });
                Debug.Assert(!string.IsNullOrEmpty(result));
            }
            TimeSpan elapsed = new TimeSpan((DateTime.Now - start).Ticks);
            Debug.Print(string.Format("Stress test with {0} iteration ran in {1} seconds", iterations.ToString(), elapsed.ToString()));
        }
    }
}
